import { shapeType_ } from "./drawBoard";

export interface Shape {
    props: Props

    actived: boolean

    selectable: boolean // 是否可以框选选中

    type: shapeType_

    draw(ctx: CanvasRenderingContext2D, osCtx: OffscreenCanvasRenderingContext2D): void;

    on(name: string, listener: Listener): void;

    getListeners(): { [name: string]: Listener[] };

    getRgbaId(): string;

    setProps(option: Props): void;
}

export interface Listener {
    (evt: MouseEvent, id: string): void;
}

export enum EventNames {
    click = 'click',
    mousedown = 'mousedown',
    mousemove = 'mousemove',
    mouseup = 'mouseup',
    mouseenter = 'mouseenter',
    mouseleave = 'mouseleave',
}
export class Props {
    id: string = ''
    name: string = ''
    width: number = 0
    height: number = 0
    x: number = 0
    y: number = 0
    bgcolor: string = 'black'
    borderWidth: number = 1
    borderColor: string = 'black'
    fontSize: string = '12px'
    textColor: string = 'black'
    text: string = ''
    scaleX: number = 1
    scaleY: number = 1
    rotation: number = 0
    size: number = 10
    textList: Array<string> = []
    textObj: Array<any> = []
    lineHeight: number = 0
    lineWidth: number = 0
    lateX: number = 0
    lateY: number = 0
    radius: number = 5
    clientX: number = 0
    clientY: number = 0
    shapes: Shape[] = []
    shadowColor: string = 'red'
    shadowBlur: number = 0
    textBaseline: CanvasTextBaseline = 'bottom'
    opacity: number = 1
    textAlign: CanvasTextAlign = 'start'
}
